基于pywinauto的自动化测试(三) |
您所在的位置:网站首页 › 模拟鼠标操作 cmd › 基于pywinauto的自动化测试(三) |
在所有的自动化测试中,不管是对于app软件CS架构还是web段的BS架构进行的自动化测试操作,流程主要分为四步骤:第一步是通过app获取到你想要操作的软件;第二步是定位到具体软件的控件;第三步是进行对控件的操作;第四步是校验操作后的结果。 第一步在前面已经详细进行介绍 这里不过多进行赘述。 第二步是定位到具体软件的控件 Dialog - 'python' (L791, T144, R1511, B915) ['python', 'Dialog', 'pythonDialog'] child_window(title="python", auto_id="xxx--测试平台", control_type="Window") | | TitleBar - '' (L-31965, T-31997, R-31774, B-31961) | ['TitleBar'] | | | | Menu - '系统' (L-31989, T-31989, R-31956, B-31956) | | ['系统', 'Menu', '系统Menu', '系统0', '系统1'] | | child_window(title="系统", auto_id="MenuBar", control_type="MenuBar") | | | | | | MenuItem - '系统' (L-31989, T-31989, R-31956, B-31956) | | | ['系统2', 'MenuItem', '系统MenuItem'] | | | child_window(title="系统", control_type="MenuItem") | | | | Button - '还原' (L-31985, T-31999, R-31914, B-31961) | | ['Button', '还原', '还原Button', 'Button0', 'Button1'] | | child_window(title="还原", control_type="Button") | | | | Button - '最大化' (L-31914, T-31999, R-31844, B-31961) | | ['Button2', '最大化Button', '最大化'] | | child_window(title="最大化", control_type="Button") | | | | Button - '关闭' (L-31844, T-31999, R-31773, B-31961) | | ['关闭', 'Button3', '关闭Button'] | | child_window(title="关闭", control_type="Button") | | Static - '姓名:' (L831, T174, R885, B190) | ['姓名:', 'Static', '姓名:Static', 'Static0', 'Static1'] | child_window(title="姓名:", control_type="Text") | | Edit - '' (L886, T174, R986, B194) | ['姓名:Edit', 'Edit', 'Edit0', 'Edit1'] | | Static - '工号:' (L1061, T174, R1115, B190) | ['Static2', '工号:', '工号:Static'] | child_window(title="工号:", control_type="Text") | | Edit - '' (L1116, T174, R1216, B194) | ['工号:Edit', 'Edit2'] | | Static - '部门: ' (L1291, T174, R1345, B190) | ['部门: ', 'Static3', '部门: Static'] | child_window(title="部门: ", control_type="Text") | | Edit - '' (L1341, T174, R1441, B194) | ['部门: Edit', 'Edit3'] | | Static - '外网IP:' (L831, T214, R885, B230) | ['Static4', '外网IP:', '外网IP:Static'] | child_window(title="外网IP:", control_type="Text") | | Edit - '' (L886, T214, R986, B234) | ['外网IP:Edit', 'Edit4'] | | Static - '用户名:' (L1061, T214, R1115, B230) | ['用户名:', 'Static5', '用户名:Static'] | child_window(title="用户名:", control_type="Text") | | Edit - '' (L1116, T214, R1216, B234) | ['Edit5', '用户名:Edit'] | | Static - '密码: ' (L1291, T214, R1345, B230) | ['Static6', '密码: ', '密码: Static'] | child_window(title="密码: ", control_type="Text") | | Edit - '' (L1341, T214, R1441, B234) | ['密码: Edit', 'Edit6'] | | Button - '录入信息' (L1341, T254, R1416, B277) | ['录入信息Button', 'Button4', '录入信息'] | child_window(title="录入信息", control_type="Button") | | Table - '' (L843, T394, R1459, B694) | ['Table', '按类型查找Table'] | | | | Pane - '' (L0, T0, R0, B0) | | ['Pane'] | | | | Header - '号码' (L844, T395, R884, B432) | | ['Header', '号码', '号码Header', 'Header0', 'Header1'] | | child_window(title="号码", control_type="Header") | | | | Header - '姓名' (L884, T395, R944, B432) | | ['Header2', '姓名Header', '姓名', '姓名0', '姓名1'] | | child_window(title="姓名", control_type="Header") | | | | Header - '工号' (L944, T395, R1094, B432) | | ['Header3', '工号', '工号Header', '工号0', '工号1'] | | child_window(title="工号", control_type="Header") | | | | Header - '部门' (L1094, T395, R1244, B432) | | ['Header4', '部门', '部门Header', '部门0', '部门1'] | | child_window(title="部门", control_type="Header") | | | | Header - '外网IP' (L1244, T395, R1394, B432) | | ['Header5', '外网IP', '外网IPHeader'] | | child_window(title="外网IP", control_type="Header") | | | | Header - '用户名' (L1394, T395, R1544, B432) | | ['Header6', '用户名', '用户名Header'] | | child_window(title="用户名", control_type="Header") | | | | Header - '密码' (L1544, T395, R1694, B432) | | ['Header7', '密码', '密码Header'] | | child_window(title="密码", control_type="Header") | | Static - '按类型查找' (L831, T257, R922, B273) | ['Static7', '按类型查找', '按类型查找Static'] | child_window(title="按类型查找", control_type="Text") | | ComboBox - '' (L921, T254, R1032, B276) | ['ComboBox外网', '按类型查找ComboBox', 'ComboBox', 'ComboBox工号', 'ComboBox部门'] | | | | ListBox - '' (L0, T0, R0, B0) | | ['ListBox'] | | | | | | ListItem - '姓名' (L0, T0, R640, B18) | | | ['ListItem', '姓名2', '姓名ListItem', 'ListItem0', 'ListItem1'] | | | child_window(title="姓名", control_type="ListItem") | | | | | | ListItem - '工号' (L0, T18, R640, B36) | | | ['ListItem2', '工号2', '工号ListItem'] | | | child_window(title="工号", control_type="ListItem") | | | | | | ListItem - '部门' (L0, T36, R640, B54) | | | ['ListItem3', '部门2', '部门ListItem'] | | | child_window(title="部门", control_type="ListItem") | | | | | | ListItem - '外网' (L0, T54, R640, B72) | | | ['ListItem4', '外网ListItem', '外网'] | | | child_window(title="外网", control_type="ListItem") | | Edit - '' (L831, T297, R941, B317) | ['按类型查找Edit', 'Edit7'] | | Button - '查找' (L956, T294, R1031, B317) | ['查找', 'Button5', '查找Button'] | child_window(title="查找", control_type="Button") | | Button - '查找全部' (L1116, T294, R1191, B317) | ['查找全部', '查找全部Button', 'Button6'] | child_window(title="查找全部", control_type="Button") child_window(title="python", auto_id="xxx--测试平台", control_type="Window") | Edit - '' (L886, T174, R986, B194)| ['姓名:Edit', 'Edit', 'Edit0', 'Edit1'] 3、 | Button - '查找' (L956, T294, R1031, B317) | ['查找', 'Button5', '查找Button'] | child_window(title="查找", control_type="Button") 这分别是图中所标记的几个典型的控件信息,这个是pywinauto自带的print_control_ identifiers所打印出的控件信息 这个控件信息有许多种类,常用的有 这就是我们第二步骤常常要定位的控件。 第三步骤中对控件自带的的方法进行操作 # 左点击,可以点进源码,还有double_click_input,right_click_input等 edit_btn.click_input() # 先ctrl+a选中所有然后再type_keys替换,和我们选中然后修改一样的 edit_btn.type_keys('^a').type_keys('xxx ', with_spaces=True) 或者使用send_keys()模拟键盘的输入的一些操作 第四步就是对结果进行验证 比如:对数据进行写入后,检查数据是否正确写入等,使用assertTrue等断言模块进行检测。 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |